{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Copyright (C)\n",
    "2016 - 2019 Pinard Liu(liujianping-ok@163.com)\n",
    "\n",
    "https://www.cnblogs.com/pinard\n",
    "\n",
    "Permission given to modify the code as long as you keep this declaration at the top\n",
    "\n",
    "scikit-learn 朴素贝叶斯类库使用小结 https://www.cnblogs.com/pinard/p/6074222.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "==Predict result by predict==\n",
      "[1]\n",
      "==Predict result by predict_proba==\n",
      "[[  9.99999949e-01   5.05653254e-08]]\n",
      "==Predict result by predict_log_proba==\n",
      "[[ -5.05653266e-08  -1.67999998e+01]]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "X = np.array([[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]])\n",
    "Y = np.array([1, 1, 1, 2, 2, 2])\n",
    "from sklearn.naive_bayes import GaussianNB\n",
    "clf = GaussianNB()\n",
    "#拟合数据\n",
    "clf.fit(X, Y)\n",
    "print \"==Predict result by predict==\"\n",
    "print(clf.predict([[-0.8, -1]]))\n",
    "print \"==Predict result by predict_proba==\"\n",
    "print(clf.predict_proba([[-0.8, -1]]))\n",
    "print \"==Predict result by predict_log_proba==\"\n",
    "print(clf.predict_log_proba([[-0.8, -1]]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
